export default {
  data () {
    return {
      thead: [
        // {
        //   type: 'selection',
        //   minWidth: 60,
        //   fixed: 'left'
        // },
        {
          title: '企业编号',
          key: 'id',
          minWidth: 100
        },
        {
          title: '新增日期',
          key: 'creatortime',
          minWidth: 180,
          render: (h, params) => {
            let row = params.row
            let date = ''
            if (row.creatortime) {
              date = row.creatortime.slice(0, 19).replace(/T/g,' ')
            }
            return h('span', date)
          }
        },
        {
          title: '企业名称',
          key: 'enterprise_name',
          minWidth: 180,
          render: (h, params) => {
            let row = params.row
            return h('span', {
              'class': 'hover-table',
              style: {
                color: '#188cc7',
                cursor: 'pointer'
              },
              on: {
                click: () => {
                  window.console.log(params)
                  this.$router.push({ name: 'enterprise-detail', query: { businessId: row.id}})
                } 
              }
            }, params.row.enterprise_name)
          }
        },
        {
          title: '公司logo',
          key: 'enterprise_logo_img',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row;
            let text = row.enterprise_logo_img ? '有' : '无';
            return h('span', text)
          }
        },
        {
          title: '营业执照',
          key: 'enterprise_business_license_img',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row;
            let text = row.enterprise_business_license_img ? '有' : '无';
            return h('span', text)
          }
        },
        {
          title: '企业类型',
          key: 'enterprise_type',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('EnterpriseType')
            let text = arr.filter((item) => {
              return item.id === row.enterprise_type
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },

        {
          title: '所属行业',
          key: 'enterprise_industry_type',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('IndustryType')
            let text = arr.filter((item) => {
              return item.id === row.enterprise_industry_type
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },

        {
          title: '所在地址',
          key: 'enterprise_address',
          tooltip: true,
          minWidth: 150
        },

        {
          title: '注册资本',
          key: 'enterprise_registered_capital_id',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('Capital_Type')
            console.log(arr)
            let text = arr.filter((item) => {
              return item.id === row.enterprise_registered_capital_id
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },

        {
          title: '公司规模',
          key: 'enterprise_scale',
          ellipsis: true,
          minWidth: 120,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('EnterpriseScaleType ')
            let text = arr.filter((item) => {
              return item.id === row.enterprise_scale
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },

        {
          title: '企业电话',
          key: 'enterprise_tel',
          minWidth: 150,
          render: (h, params) => {
            let row = params.row
            let str = ''
            if (row.enterprise_tel) {
              str = row.enterprise_tel
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },

        {
          title: '企业邮箱',
          key: 'enterprise_email',
          minWidth: 180,
          render: (h, params) => {
            let row = params.row
            let str = ''
            if (row.enterprise_email) {
              str = row.enterprise_email
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        }
      ]
    }
  },
  methods: {
    // 获取分享招聘各种状态
    getStatusFn (encode) {
      let allStatus = JSON.parse(localStorage.getItem('FXZP_STATUS'))
      // console.log(allStatus)
      let statusArr = allStatus.filter((item) => {
        return item.e_encode === encode
      })
      return statusArr 
    }
  }
}
